using UnityEngine;

public class ButtonShoot : MonoBehaviour
{
	private bool press;

	public void OnPress(bool isDown)
	{
		if (GameController.instance.playerScript.isShock || GameController.instance.playerScript.isDead)
		{
			return;
		}
		if (PlayerBehavior.MyPlayer.currentCar == null)
		{
			if (isDown)
			{
				if (GameController.instance.playerScript.canShoot)
				{
					TPSCamera.instance.SetStreifCamera();
					GameController.instance.playerScript.isShooting = true;
				}
			}
			else
			{
				GameController.instance.playerScript.isShooting = false;
			}
		}
		else if (PlayerBehavior.MyPlayer.currentCar is TitanBehavior)
		{
			GameController.instance.playerScript.isShooting = false;
			((TitanBehavior)PlayerBehavior.MyPlayer.currentCar).mainWeaponsShooting = isDown;
			((TitanBehavior)PlayerBehavior.MyPlayer.currentCar).additionalWeaponsShooting = isDown;
		}
		CameraZoneEnabler.GetCameraZone().shootfromButton = isDown;
		CameraZoneEnabler.GetCameraZone().PressFromButton(isDown);
	}

	private void OnDisable()
	{
		CameraZoneEnabler.GetCameraZone().OnPress(false);
		if ((bool)GameController.instance && (bool)GameController.instance.playerScript)
		{
			GameController.instance.playerScript.isShooting = false;
		}
	}

	private void Update()
	{
		if (GameController.instance.playerScript.isShock && GameController.instance.playerScript.isShooting)
		{
			GameController.instance.playerScript.isShooting = false;
		}
		if (!GameController.instance.playerScript.canShoot)
		{
			GameController.instance.playerScript.isShooting = false;
		}
	}
}
